<!--用户的购物车页面-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.id" placeholder="请输入购物车id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.productId" placeholder="请输入商品ID" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.specsId" placeholder="请输入规格id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.userId" placeholder="请输入用户id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe highlight-current-row
                @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
                style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="购物车id" header-align="center" align="center" width="150" fixed></el-table-column>
        <el-table-column prop="productId" label="商品ID" header-align="center" align="center"width="150" fixed></el-table-column>
        <el-table-column prop="specsId" label="规格id" header-align="center" align="center"width="150" fixed></el-table-column>
        <el-table-column prop="userId" label="用户id" header-align="center" align="center"width="180" fixed></el-table-column>
        <el-table-column prop="price" label="商品价格" header-align="center" align="center"width="100"></el-table-column>
        <el-table-column prop="quantity" label="商品数量" header-align="center" align="center"width="90"></el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center"></el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>

  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './userCartAddOrUpdate.vue'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/api/userCart/page',
        getDataListIsPage: true,
        deleteURL: '/api/userCart',
        deleteIsBatch: true
      },
      dataForm: {
        id: '',
        price: '',            //表示购物车中该商品的单价，可以是原价或促销价
        productId: '',        //关联到商品表的ID，用于与商品进行关联，表示购物车中的商品
        quantity:'',          //表示购物车中该商品的数量
        specsId: '',          //规格ID
        userId: ''            //关联到用户表的ID，用于与用户进行关联，表示购物车属于哪个用户
      },
    }
  },
  components: {
    AddOrUpdate
  },
  created() {

  },
  methods: {}
}
</script>
